<?php
// Redirect output to a client’s web browser (Excel5)
header("Content-type: application/vnd.pdf");
header("Content-Disposition: attachment; filename=demo.pdf");
header('Cache-Control: max-age=0');

// PHPExcel

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set Orientation, size and scaling
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);

// Generate spreadsheet
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'pdf');
$objWriter->save('php://output');
exit;
?>